/*    */ package server.events;
/*    */ 
/*    */ import client.MapleCharacter;
import server.Timer;
import tools.MaplePacketCreator;

import java.util.concurrent.ScheduledFuture;

/*    */
/*    */
/*    */
/*    */ 
/*    */ public class MapleSurvival
/*    */   extends MapleEvent
/*    */ {
/* 11 */   protected final long time = 360000L;
/* 12 */   protected long timeStarted = 0L;
/*    */   protected ScheduledFuture<?> olaSchedule;
/*    */   
/*    */   public MapleSurvival(int channel, MapleEventType type) {
/* 16 */     super(channel, type);
/*    */   }
/*    */ 
/*    */   
/*    */   public void finished(MapleCharacter chr) {
/* 21 */     givePrize(chr);
/* 22 */     chr.finishAchievement(25);
/*    */   }
/*    */ 
/*    */   
/*    */   public void onMapLoad(MapleCharacter chr) {
/* 27 */     super.onMapLoad(chr);
/* 28 */     if (isTimerStarted()) {
/* 29 */       chr.send(MaplePacketCreator.getClock((int)(getTimeLeft() / 1000L)));
/*    */     }
/*    */   }
/*    */ 
/*    */   
/*    */   public void startEvent() {
/* 35 */     unreset();
/* 36 */     super.reset();
/* 37 */     broadcast(MaplePacketCreator.getClock(360));
/* 38 */     this.timeStarted = System.currentTimeMillis();
/*    */     
/* 40 */     getClass(); this.olaSchedule = Timer.EventTimer.getInstance().schedule(() -> { for (int i = 0; i < this.type.mapids.length; i++) { for (MapleCharacter chr : getMap(i).getCharactersThreadsafe()) warpBack(chr);  unreset(); }  },360000L);
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */     
/* 48 */     broadcast(MaplePacketCreator.serverNotice(0, "The portal has now opened. Press the up arrow key at the portal to enter."));
/* 49 */     broadcast(MaplePacketCreator.serverNotice(0, "Fall down once, and never get back up again! Get to the top without falling down!"));
/*    */   }
/*    */   
/*    */   public boolean isTimerStarted() {
/* 53 */     return (this.timeStarted > 0L);
/*    */   }
/*    */   
/*    */   public long getTime() {
/* 57 */     return 360000L;
/*    */   }
/*    */   
/*    */   public void resetSchedule() {
/* 61 */     this.timeStarted = 0L;
/* 62 */     if (this.olaSchedule != null) {
/* 63 */       this.olaSchedule.cancel(false);
/*    */     }
/* 65 */     this.olaSchedule = null;
/*    */   }
/*    */ 
/*    */   
/*    */   public void reset() {
/* 70 */     super.reset();
/* 71 */     resetSchedule();
/* 72 */     getMap(0).getPortal("join00").setPortalState(false);
/*    */   }
/*    */ 
/*    */   
/*    */   public void unreset() {
/* 77 */     super.unreset();
/* 78 */     resetSchedule();
/* 79 */     getMap(0).getPortal("join00").setPortalState(true);
/*    */   }
/*    */   
/*    */   public long getTimeLeft() {
/* 83 */     return 360000L - System.currentTimeMillis() - this.timeStarted;
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\server\events\MapleSurvival.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */